
#ifndef __UI_TOUCH_H
#define	__UI_TOUCH_H

#include <stdint.h>
#include "dataproc.h"

#ifdef	__cplusplus
extern "C" {
#endif
	

struct ui_touch_obj_str
{
    struct 
    {
        int16_t x,y;
    } site;
    struct 
    {
        int16_t x,y;
    } size;
    uint32_t user_data;
    void (*press_callback)(struct ui_touch_obj_str * info);
	void (*press_edge_callback)(struct ui_touch_obj_str * info);
	void (*release_callback)(struct ui_touch_obj_str * info);
    struct ui_touch_obj_str * next;
};

typedef struct ui_touch_obj_str ui_touch_obj_type;


struct ui_text_in_obj_str
{
    int16_t index_next;
    int16_t len; //可输入数为len-1，保证末尾为0
    int16_t len_remain; //剩余可输入数
    uint8_t b_rang_en; //数字文本范围检测开关
    uint8_t in_pn; //数字文本整数小数位数，整数不包含符号位
    int32_t num; //数字文本时，用于存储结果，纯文本无效
    int32_t min; //数字文本时，数值最小值，纯文本无效
    int32_t max; //数字文本时，数值最大值，纯文本无效
    char * buff;
};
typedef struct ui_text_in_obj_str ui_text_in_obj_type;

/*****************************************************************************
* @brief  touch key check.
* \param[in] list     按键数组地址
* \param[in] list_len 按键数组长度
* \param[in] x 触摸点x坐标
* \param[in] y 触摸点y坐标
* \retval: key val
*****************************************************************************/
char ui_touch_point_check(ui_touch_obj_type *list, uint16_t list_len, int16_t x, int16_t y);

/*****************************************************************************
* @brief  touch key check.
* \param[in] x    触摸区起始坐标x
* \param[in] y    触摸区起始坐标y
* \param[in] wide 触摸区宽度
* \param[in] high 触摸区高度
* \retval: val
*****************************************************************************/
void ui_touch_rang_set(int16_t x, int16_t y, int16_t wide, int16_t high);


/*****************************************************************************
* @brief  text input.
* \param[in] ch     按键数组地址
*****************************************************************************/
void ui_text_input_reset(ui_text_in_obj_type *obj, uint8_t *buff, int16_t len);
uint8_t ui_text_input_add(ui_text_in_obj_type *obj,  uint8_t ch);
void ui_text_input_del(ui_text_in_obj_type *obj);

/*****************************************************************************
* @brief  number text input.
* \param[in] ch     按键数组地址
*****************************************************************************/
void ui_num_text_input_rang(ui_text_in_obj_type *obj, uint8_t en, int32_t min, int32_t max);
void ui_num_text_input_inpn_set(ui_text_in_obj_type *obj, uint8_t in, uint8_t pn);
uint8_t ui_num_text_input_add(ui_text_in_obj_type *obj,  uint8_t ch);
void ui_num_text_input_del(ui_text_in_obj_type *obj);

#ifdef	__cplusplus
}
#endif

#endif	/* __UI_TOUCH_H */
